// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import filters from './filters'; // 全局vue filter

import api from '@/util/api'
import tools from '@/util/tools'

import MintUI from 'mint-ui'
import 'mint-ui/lib/style.css'
Vue.use(MintUI)

Vue.prototype.api = api;
Vue.config.productionTip = false
// 注册全局过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
});



if (process.env.NODE_ENV == 'development') {
  Vue.prototype.mp_id = '2558833265649404ae3347458a1a5c5a32292363';
  Vue.prototype.mp_info = {
    wx_qrcode_url: 'http://mmbiz.qpic.cn/mmbiz/13Y0Tvc8TjLnAmRGQw2Bss9ibDGDYEfEMNxO4ZicTBALYcNpwOtExEzgDwObvicCRpfGubvf950H3HTaY0kNiaVdLQ/0',
    wx_type: '2',
    verify_type: '1'
  };
  Vue.prototype.from_mp_id = '2558833265649404ae3347458a1a5c5a32292363';
  Vue.prototype.from_mp_info = {
    wx_qrcode_url: 'http://mmbiz.qpic.cn/mmbiz/13Y0Tvc8TjLnAmRGQw2Bss9ibDGDYEfEMNxO4ZicTBALYcNpwOtExEzgDwObvicCRpfGubvf950H3HTaY0kNiaVdLQ/0',
    wx_type: '2',
    verify_type: '0'
  };
  Vue.prototype.team_id = '26235843f9373aa65e6144a8b308d234cecc8463 '; // 微课堂teamid
  Vue.prototype.from_team_id = ''; // from teamid
  Vue.prototype.wx_open_id = 'odTSkt5qViNUboE2s5iN7UPejvpY';
  Vue.prototype.wx_user_id = '62392785dc4e8b3b33464ae291fb232a1379fc18'; //'26235784d9b3ca0867ab47fb9db959a7e0bf3ab1' '245793953ce5f8ec15874b43a900e847803faed3';
  Vue.prototype.wx_pay_way = 'from_special_self';
  Vue.prototype.unified_pay_host = 'xueban.vstudy.net.cn';
  Vue.prototype.current_host = 'http://xueban.vstudy.net.cn';
  Vue.prototype.IS_DEBUG = 'True'; // True：测试服务器， False：正式服务器
  Vue.prototype.relate_openid = ''; // 关联的其他团队下认证服务号openid
} else {
  Vue.prototype.mp_id = p_global.mp_id;
  Vue.prototype.mp_info = p_global.mp_info;
  Vue.prototype.from_mp_id = p_global.from_mp_id;
  Vue.prototype.from_mp_info = p_global.from_mp_info;
  Vue.prototype.from_team_id = p_global.from_team_id;
  Vue.prototype.team_id = p_global.team_id;
  Vue.prototype.wx_open_id = p_global.wx_open_id; // window.localStorage.getItem('WXOPENID' + p_global.mp_id) || ''; //localStorage p_global.wx_open_id;
  Vue.prototype.wx_user_id = p_global.wx_user_id; // window.localStorage.getItem('WXUSERID' + p_global.mp_id) || ''; //p_global.wx_user_id;
  Vue.prototype.wx_pay_way = p_global.wx_pay_way;
  Vue.prototype.unified_pay_host = p_global.unified_pay_host;
  Vue.prototype.current_host = window.location.origin;
  Vue.prototype.IS_DEBUG = p_global.IS_DEBUG;
  Vue.prototype.relate_openid = p_global.relate_openid;
}

// 路由控制
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next() // 确保一定要调用 next()
})
/* eslint-disable no-new */
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
